package com.leaveworkframework.core.search;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class PagingRequest {
	private Map<String, Object> serachCondition = Collections.emptyMap();

	private Order order;

	public Map<String, Object> getSerachCondition() {
		return serachCondition;
	}

	public PagingRequest addSearchCondition(String key, Object value) {
		if (serachCondition.isEmpty()) {
			serachCondition = new HashMap<String, Object>();
		}
		this.serachCondition.put(key, value);

		return this;
	}

	Pagination pagination;

	public PagingRequest setOrder(Order order) {
		this.order = order;
		return this;
	}

	public PagingRequest setCurrentPageIndex(long currentPageIndex) {
		if (this.pagination == null) {
			this.pagination = new Pagination();
		}

		this.pagination.currentPageIndex = currentPageIndex;

		return this;
	}

	public PagingRequest setPagePerRow(long pagePerRow) {
		if (this.pagination == null) {
			this.pagination = new Pagination();
		}
		this.pagination.pagePerRow = pagePerRow;

		return this;
	}

}
